package cn.iocoder.yudao.module.design.dal.mysql.relatived;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.design.controller.admin.relatived.vo.RelativedExportReqVO;
import cn.iocoder.yudao.module.design.controller.admin.relatived.vo.RelativedPageReqVO;
import cn.iocoder.yudao.module.design.controller.admin.relatived.vo.RelativedSupplierVO;
import cn.iocoder.yudao.module.design.dal.dataobject.relatived.RelativedDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 关联人 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface RelativedMapper extends BaseMapperX<RelativedDO> {

    default PageResult<RelativedDO> selectPage(RelativedPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RelativedDO>()
                .eqIfPresent(RelativedDO::getUserId, reqVO.getUserId())
                .eqIfPresent(RelativedDO::getUserCd, reqVO.getUserCd())
                .eqIfPresent(RelativedDO::getRelUserId, reqVO.getRelUserId())
                .eqIfPresent(RelativedDO::getRelUserCd, reqVO.getRelUserCd())
                .likeIfPresent(RelativedDO::getNickName, reqVO.getNickName())
                .eqIfPresent(RelativedDO::getRelationStatus, reqVO.getRelationStatus())
                .betweenIfPresent(RelativedDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(RelativedDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(RelativedDO::getFinishTime, reqVO.getFinishTime())
                .orderByDesc(RelativedDO::getId));
    }

    default List<RelativedDO> selectList(RelativedExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<RelativedDO>()
                .eqIfPresent(RelativedDO::getUserId, reqVO.getUserId())
                .eqIfPresent(RelativedDO::getUserCd, reqVO.getUserCd())
                .eqIfPresent(RelativedDO::getRelUserId, reqVO.getRelUserId())
                .eqIfPresent(RelativedDO::getRelUserCd, reqVO.getRelUserCd())
                .likeIfPresent(RelativedDO::getNickName, reqVO.getNickName())
                .eqIfPresent(RelativedDO::getRelationStatus, reqVO.getRelationStatus())
                .betweenIfPresent(RelativedDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(RelativedDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(RelativedDO::getFinishTime, reqVO.getFinishTime())
                .orderByDesc(RelativedDO::getId));
    }
    default List<RelativedDO> selectListByUserId(Long userId,String statusCd) {
        return selectList(new LambdaQueryWrapperX<RelativedDO>()
                .eqIfPresent(RelativedDO::getUserId, userId)
                .eqIfPresent(RelativedDO::getRelationStatus,statusCd)
                .orderByDesc(RelativedDO::getId));
    }
    /**
     * 查询关联人
     * @param userId
     * @param roleId
     * @return
     */
    List<Map> getRelativedRelList(@Param("userId") String userId, @Param("roleId") String roleId);

    /**
     * 查询关联人
     * @param userId
     * @param roleId
     * @return
     */
    List<Map> getFriendList(@Param("userId") Long userId, @Param("roleId") String roleId);


    /**
     * 查询关联人
     * @param userId
     * @param roleId
     * @return
     */
    List<RelativedSupplierVO> getRelativedRelSupplierList(@Param("userId") String userId, @Param("roleId") String roleId);

    List<Map<String, Object>> getSimFriendList(@Param("userId") Long userId, @Param("roleId") String roleId);
}
